using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class HomeSettings : MonoBehaviour
{
	//[Header("Home")]
	//public RectTransform noAdsButton;

	//public RectTransform settingsButton;

	[Header("Popup")]
	public GameObject settingsPopupObject;

	public Image fadeImage;

	public RectTransform popupTransform;

	[Header("Vibrations")]
	public Image vibrationIcon;

	public Sprite vibrationOnSprite;

	public Sprite vibrationOffSprite;

	public Text vibrationText;

	[Header("GDPR")]
	public GameObject GDPRObject;

	private Tween _displayTween;

	private bool _canClosePopup;

	private void Awake()
	{
	//	settingsPopupObject.SetActive(value: false);
	}

	private void Start()
	{
		UpdateVibrationButton();
		//VoodooServiceLocator.Ads.RequestGdprApplicability(OnGDPRApplicabiliy);
	}

	public void DisplayWithAnimation(bool state)
	{
		if (_displayTween != null)
		{
			_displayTween.Kill();
		}
		if (state)
		{
			//_displayTween = DOTween.Sequence().Join(noAdsButton.DOAnchorPosX(95f, 0.2f).SetEase(Ease.OutBack)).Join(settingsButton.DOAnchorPosX(110f, 0.2f).SetEase(Ease.OutBack));
		}
		else
		{
			//_displayTween = DOTween.Sequence().Join(noAdsButton.DOAnchorPosX(250f, 0.2f)).Join(settingsButton.DOAnchorPosX(250f, 0.2f));
		}
	}

	public void CALLBACK_BUTTON_OpenSettings()
	{
		_canClosePopup = false;
		settingsPopupObject.SetActive(value: true);
		HomeManager.Instance.DisplayHomeUI(state: false);
		fadeImage.color = new Color(0f, 0f, 0f, 0f);
		fadeImage.DOFade(0.4f, 0.3f).OnComplete(delegate
		{
			_canClosePopup = true;
		});
		popupTransform.anchoredPosition = new Vector2(0f, -600f);
		popupTransform.DOAnchorPosY(30f, 0.2f).SetDelay(0.2f).SetEase(Ease.OutBack);
	}

	public void CALLBACK_BUTTON_CloseSettings()
	{
		if (_canClosePopup)
		{
			_canClosePopup = false;
			fadeImage.DOKill();
			fadeImage.DOFade(0f, 0.3f).OnComplete(delegate
			{
				settingsPopupObject.SetActive(value: false);
				HomeManager.Instance.DisplayHomeUI(state: true);
			});
			popupTransform.DOKill();
			popupTransform.anchoredPosition = new Vector2(0f, 30f);
			popupTransform.DOAnchorPosY(-600f, 0.2f);
		}
	}

	public void CALLBACK_BUTTON_ShowPrivacyPolicy()
	{
		//VoodooServiceLocator.Ads.ShowGDPRSettings();
	}

	public void CALLBACK_BUTTON_ToggleVibrations()
	{
		PlayerData.Instance.Vibrations = !PlayerData.Instance.Vibrations;
		PlayerData.Instance.SaveData();
		UpdateVibrationButton();
	}

	public void OnGDPRApplicabiliy(bool b)
	{
		GDPRObject.SetActive(b);
	}

	private void UpdateVibrationButton()
	{
		if (PlayerData.Instance.Vibrations)
		{
			//vibrationIcon.sprite = vibrationOnSprite;
			//vibrationText.text = string.Format("{0}\n{1}", LocalizationManager.GetTranslation("TXT_VIBRATIONS"), LocalizationManager.GetTranslation("TXT_YES"));
		}
		else
		{
			//vibrationIcon.sprite = vibrationOffSprite;
			//vibrationText.text = string.Format("{0}\n{1}", LocalizationManager.GetTranslation("TXT_VIBRATIONS"), LocalizationManager.GetTranslation("TXT_NO"));
		}
	}
}
